<template>
  <halo-dialog :visible="visible">
    <div class="card">
      <div :style="{ backgroundColor: color }" class="icon-box">
        <i class="iconfont icon-check"></i>
      </div>
      <div class="title">{{ title }}</div>
      <slot name="desc" v-if="desc">
        <div class="desc">{{ desc }}</div>
      </slot>
      <div :style="{ backgroundColor: color }" class="btn" @click="confirm">{{ btn }}</div>
    </div>
  </halo-dialog>
</template>

<script>
import HaloDialog from '../halo-dialog';

export default {
  components: {
    HaloDialog,
  },
  props: {
    color: {
      type: String,
      default: '#2978FF',
    },
  },
  data() {
    return {
      visible: false,
      title: '服务单确认成功',
      desc: '感谢您的信任',
      btn: '查看',
      callback: () => {},
    };
  },
  methods: {
    show({ title, desc, btn }, callback) {
      this.visible = true;
      title && (this.title = title);
      btn && (this.btn = btn);
      this.desc = desc;
      callback && (this.callback = callback);
    },
    confirm() {
      this.callback && this.callback();
      this.visible = false;
    },
  },
};
</script>

<style lang="less" scoped>
.card {
  width: 610px;
  padding-bottom: 160px;
  background: #ffffff;
  border-radius: 12px;
  overflow: hidden;
  text-align: center;
  position: relative;
  .icon-box {
    width: 96px;
    height: 96px;
    background: #2978ff;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 60px auto 40px;
    border-radius: 50%;
  }
  .iconfont {
    font-size: 50px;
    color: white;
    font-weight: bold;
  }
  .title {
    font-size: 36px;
    color: #323038;
  }
  .desc {
    font-size: 28px;
    font-weight: 400;
    color: #68676c;
    padding-top: 30px;
  }
  .btn {
    width: 100%;
    height: 100px;
    background: #2978ff;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 32px;
    position: absolute;
    left: 0;
    bottom: -2px;
  }
}
</style>